This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
library("hdxstats")
library("dplyr")
library("ggplot2")
library("RColorBrewer")
library("tidyr")
library("pheatmap")
library("scales")
library("viridis")
library("patchwork")
library("Biostrings")
library("xfun")
#data_filepath <- "vignettes/data/MBPqDF_test.rsd"
#hdx_data <- extract_hdx_data(data_filepath) # DONE
# TEST 1
# INPUT
data_selection <- hdx_data[,1:24]
all_peptides <- rownames(data_selection)[[1]]
starting_parameters <- list(a = NULL, b = 0.001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "fit",
peptide_selection = all_peptides,
start = starting_parameters)
[1] "INFO: Performing fitting of Deuterium uptake kinetics. Method: 'hdxstats::fitUptakeKinetics' "
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "Could not fit model, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "Could not fit model, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
Error in nlsModel(formula, mf, start, wts) :
singular gradient matrix at initial parameter estimates
[1] "model fit failed, likely exessive missing values"
results$method
[1] "fitUptakeKinetics"
graphics_kinetic <- visualise_hdx_data(results, type="kinetics")
[1] "INFO: I found 104 models in your results data."
graphics_kinetic[[1]] | graphics_kinetic[[2]] | graphics_kinetic[[3]]
graphics <- visualise_hdx_data(results, type="forest")
[1] "INFO: I found 104 models in your results data."
graphics[[1]] | graphics_kinetic[[1]]
graphics[[1]]$data
data_selection <- hdx_data[,1:100]
all_peptides <- rownames(data_selection)[[1]] # get all peptides
starting_parameters <- list(a = NULL, b = 0.0001, d = NULL, p = 1)
# OUTPUT
results <- analyse_kinetics(data = data_selection,
method = "dfit",
peptide_selection = all_peptides[37],
start = starting_parameters)
[1] "INFO: Performing differential fitting of Deuterium uptake kinetics. Method: 'hdxstats::differentialUptakeKinetics' "
[1] "INFO: You did not specify a 'formula' for your fitting model."
[1] "INFO: Fitting will be performed for (default): 'formula <- value ~ a * (1 - exp(-b*(timepoint)^p)) + d' "
graphics <- visualise_hdx_data(results, type="kinetics")
[1] "INFO: I found 7 models in your results data."
colnames(HOIP)
[1] "Protein" "Start" "End" "Sequence" "Modification" "Fragment" "MaxUptake" "MHP" "State"
[10] "Exposure" "Center" "Center.SD" "Uptake" "Uptake.SD" "RT" "RT.SD"
EXAMPLE: Tutorial 1
csv_filename <- "MBP.csv"
csv_filepath <- system.file("extdata", csv_filename, package = "hdxstats")
data <- read.csv(csv_filepath)
columns_names <- c("hx_time", "replicate_cnt", "hx_sample") # to merge into new column names
columns_fixed <- c("pep_sequence", "pep_charge")
# transform data
data_wide <- pivot_wider(data.frame(data),
values_from = d, # Deu_Uptake
names_from = columns_names, # Exposure_Time, Replicate, Other
id_cols = columns_fixed) # Sequence, Charge
Error in pivot_wider(data.frame(data), values_from = d, names_from = columns_names, :
could not find function "pivot_wider"
EXAMPLE: Tutorial 3 (HOIP)
HOIPpath <- system.file("extdata", "N64184_1a2_state.csv", package = "hdxstats")
HOIP <- read.csv(HOIPpath)
HOIP_wide <- pivot_wider(data.frame(HOIP),
values_from = Center, # Deu_Uptake
names_from = c("Exposure", "State"), # Exposure_Time, State
id_cols = c("Sequence")) # Sequence
EXAMPLE: Case study
secA <- read.csv("inst/extdata/Project_2_SecA_Cluster_Data.csv")
secA_wide <- pivot_wider(data.frame(secA),
values_from = "Center", # Deu_Uptake
names_from = c("Exposure", "File", "State"), # Exposure_Time, Other, State
id_cols = c("Sequence", "z")) # Sequence, Charge